home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
8352
/
8352.xpi
/
chrome
/
greasefire.jar
/
content
/
test
/
test_updater.js
< prev
next >
Wrap
Text File
|
2009-01-06
|
2KB
|
77 lines
/*
* Copyright (C) 2008 by Steve Krulewitz <skrulx@gmail.com>
* Licensed under GPLv2 or later, see file LICENSE in the xpi for details.
*/
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
function runTest() {
var tm = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager);
var mainThread = tm.mainThread;
var gfs = Cc["@skrul.com/greasefire/service;1"]
.getService(Ci.gfIGreasefireService);
var u = Cc["@skrul.com/greasefire/updater;1"]
.getService(Ci.gfIUpdaterService);
log("index date" + (new Date(gfs.indexDate)));
var done = false;
var doCancel = false;
u.addListener({
onUpdateStarted: function() {
log("onUpdateStarted");
if (doCancel) {
log("cancelling");
u.cancelUpdate();
}
},
onUpdateFinished: function(aStatus, aMessage) {
log("onUpdateFinished " + aStatus.toString(16) + " " + aMessage);
done = true;
},
onDownloadProgress: function(aCurrentBytes, aTotalBytes) {
//log("onDownloadProgress " + aCurrentBytes + " " + aTotalBytes);
}
});
u.startUpdate(true);
while (!done) {
mainThread.processNextEvent(true);
}
log("index date" + (new Date(gfs.indexDate)));
done = false;
u.startUpdate(false);
while (!done) {
mainThread.processNextEvent(true);
}
log("index date" + (new Date(gfs.indexDate)));
/*
doCancel = true;
done = false;
u.startUpdate(true);
while (!done) {
mainThread.processNextEvent(true);
}
log("index date" + (new Date(gfs.indexDate)));
*/
return true;
}
function newUri(spec) {
var ioService = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
return ioService.newURI(spec, null, null);
}